package Main;

import java.text.SimpleDateFormat;
import java.util.Calendar;

import javax.swing.JOptionPane;

public class AutoAction extends Thread {

	private int sleep;
	private boolean keepAlive = true;
	private MyController myc;

	public AutoAction(int ms, MyController myc) {
		this.sleep = ms;
		this.myc=myc;
		this.run();
	}

	public void run() {
		while (keepAlive) {
			try {
				sleep((this.sleep));
				Calendar cal = Calendar.getInstance();
		    	
		    	SimpleDateFormat sdfT = new SimpleDateFormat("HH:mm:ss");
		    	SimpleDateFormat sdfD = new SimpleDateFormat("dd.MM.YYYY");
				myc.setTimeString(sdfT.format(cal.getTime())+"  -  "+sdfD.format(cal.getTime())+"     ");
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		this.stopThread();
	}

	public void stopThread() {
		this.keepAlive = false;
	}

}
